package net.lukecloud.xile.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import net.lukecloud.xile.App;
import net.lukecloud.xile.activity.FindDevicesActivity;
import net.lukecloud.xile.activity.LauncherActivity;
import net.lukecloud.xile.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MeFragment extends Fragment {
    public MeFragment() {
    }

    @BindView(R.id.imageView)  ImageView mImageView;

    // TODO: Customize parameter initialization
    @SuppressWarnings("unused")
    public static MeFragment newInstance(int columnCount) {
        MeFragment fragment = new MeFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.me_fragment, container, false);
        TextView name =(TextView) view.findViewById(R.id.name);
        name.setText(((App)getActivity().getApplication()).show_name);
        ButterKnife.bind(this, view);
//        mImageView.setImageURI();
        return view;
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
//        if (context instanceof OnListFragmentInteractionListener) {
//            mListener = (OnListFragmentInteractionListener) context;
//        } else {
//            throw new RuntimeException(context.toString()
//                    + " must implement OnListFragmentInteractionListener");
//        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
//        mListener = null;
    }

    @OnClick(R.id.button_exit)
    public void submit(View view) {
        ((App)getActivity().getApplication()).cancel();
        getActivity().finish();
        startActivity(new Intent(getActivity(), LauncherActivity.class));
    }

    @OnClick(R.id.button_wifi)
    public void wifi(View view) {
        startActivity(new Intent(getActivity(), FindDevicesActivity.class));
    }

}
